﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using TreeGraphicalControl;
//using FeatureModelCore;
//using Collections.TreeCollections;
//using System.Windows.Controls;
//using System.Windows;
//using FeatureModelTool.FeatureModelView.MenuItems;
//using FeatureModelTool.Windows;
//using FeatureModelCore.FMTypes;
//using System.Windows.Media;

//namespace FeatureModelTool.FeatureModelView.TreeViewItems
//{
//    public class TreeItem_Relationship : TreeViewItemControl
//    {
//        public FeatureTreeRelationship FeatureInstance { get; protected set; }

//        private readonly static string _ICON_SOURCE = "/FeatureModelTool;component/Images/r.png";
//        private readonly static Brush _COMMON_COLOR = Brushes.LemonChiffon;

//        public TreeItem_Relationship(FeatureTreeRelationship relationship)
//        {
//            FeatureInstance = relationship;
//            this.Header = MainWindow.GenerateTreeItemHeader(this.FeatureInstance.Type.ToString(), _ICON_SOURCE
//                , _COMMON_COLOR);
//            //this.BorderBrush = Brushes.Black;
//            //this.BorderThickness = new Thickness(1, 1, 1, 1);
//        }
//        /// <summary>
//        /// Tree Item Construct
//        /// </summary>
//        /// <param name="treeObj"></param>
//        /// <returns></returns>
//        public static TreeViewItemControl ConstructTreeItem(TreeObject treeObj)
//        {
//            FeatureTreeRelationship projFile = treeObj as FeatureTreeRelationship;
//            if (projFile == null)
//            {
//                return null;
//            }
//            return new TreeItem_Relationship(projFile);
//        }

//        #region Context Generator
//        /// <summary>
//        /// Context Generator
//        /// </summary>
//        /// <param name="treeRoot"></param>
//        /// <returns></returns>
//        public static ContextMenu GenerateContext(TreeViewItemControl treeItem, TreeObject treeObj)
//        {
//            FeatureTreeRelationship relationship = treeObj as FeatureTreeRelationship;
//            TreeItem_Relationship treeItem_R = treeItem as TreeItem_Relationship;
//            if (relationship == null)
//            {
//                return null;
//            }

//            // new Tree Node
//            MenuItem_Relationship newTreeNode = new MenuItem_Relationship(treeItem_R, relationship)
//            {
//                Name = relationship.ID.ToString(),
//                Header = "New Feature Tree Node"
//            };
//            newTreeNode.Click += new RoutedEventHandler(NewTreeNode_EventHandler);

//            // edit
//            MenuItem_Relationship editTreeNode = new MenuItem_Relationship(treeItem_R, relationship)
//            {
//                Name = relationship.ID.ToString(),
//                Header = "Edit"
//            };
//            editTreeNode.Click += new RoutedEventHandler(Edit_EvenetHandler);

//            // delete
//            MenuItem_Relationship delete = new MenuItem_Relationship(treeItem_R, relationship)
//            {
//                Name = relationship.ID.ToString(),
//                Header = "Delete"
//            };
//            delete.Click += new RoutedEventHandler(TreeItem_Root.Delete_EventHanlder);

//            ContextMenu contextMenu = new ContextMenu();
//            contextMenu.Items.Add(newTreeNode);
//            contextMenu.Items.Add(editTreeNode);
//            contextMenu.Items.Add(delete);

//            return contextMenu;
//        }
//        /// <summary>
//        /// New Feature Tree Node
//        /// </summary>
//        /// <param name="sender"></param>
//        /// <param name="e"></param>
//        public static void NewTreeNode_EventHandler(object sender, RoutedEventArgs e)
//        {
//            MenuItem_Relationship relationship = sender as MenuItem_Relationship;
//            if (relationship == null)
//            {
//                return;
//            }
//            NewFeatureTreeNodeDialog dia = new NewFeatureTreeNodeDialog();
//            dia.ShowDialog();

//            if (dia.Dirty == false)
//            {
//                return;
//            }

//            FeatureModelTree tree = (FeatureModelTree)relationship.FeatureInstance.TreeOwner;
//            //FeatureTreeNode node = tree.CreateFeatureNode(relationship.FeatureInstance);
//            //node.FeatureName = dia.TreeNodeName;
//        }
//        /// <summary>
//        /// Edit Type of cross contraints
//        /// </summary>
//        /// <param name="sender"></param>
//        /// <param name="e"></param>
//        public static void Edit_EvenetHandler(object sender, RoutedEventArgs e)
//        {
//            MenuItem_Relationship r = sender as MenuItem_Relationship;
//            if (r == null)
//            {
//                return;
//            }
//            Array types = Enum.GetValues(typeof(FMTreeRelationshipType));
//            EditTypeDialog dia = new EditTypeDialog(types, r.FeatureInstance.Type);
//            dia.ShowDialog();

//            if (dia.Dirty == true)
//            {
//                r.FeatureInstance.Type = (FMTreeRelationshipType)dia.RType;
//            }
//        }
//        #endregion
//    }
//}
